#ifndef __FTPSERVER_H__
#define __FTPSERVER_H__

typedef struct FtpServer_t FtpServer;

/*  List of errors can be accepted by clients in the header of the packet (see the "Ftp protocol" for details)          */
typedef enum FtpErrMsg_t
{
    FTP_SUCCESS = 0,
    FTP_ERR_BAD_CMD ,               /*  Invalid command                                                                 */
    FTP_ERR_CONN_ERR ,              /*  Error in establish connection with client                                       */
    FTP_ERR_CLIENT_NOT_FOUND ,      /*  Client not found in the server data base. Require new connection                */
    FTP_ERR_WRONG_USR   ,           /*  Invalid user                                                                    */
    FTP_ERR_WRONG_PASS   ,          /*  Invalid password to the current user                                            */
    FTP_ERR_WRONG_PASS3   ,         /*  Invalid password to current user insertred 3 times. go back wait for user       */
    FTP_ERR_FILE_NOT_EXIST  ,       /*  Requested file for transfer not exist                                           */
    FTP_ERR_READ_FILE_FAIL ,        /*  Error occured while reading file                                                */
    FTP_ERR_FILE_TRANS  ,           /*  Error occured during preparing the file transfer                                */
    FTP_ERR_CD  ,                   /*  Error occured during the change directory procedure (generally alloc problem)   */
    FTP_ERR_DIR_NOT_EXIST ,         /*  The directory to change to doesn't exist                                        */
    FTP_ERR_LS            ,         /*  Error occured during try to ls                                                  */
    FTP_ERR_CREATE_FILE             /*  Error on creating file on server for the "put" command                          */
}FtpErrMsg;


/*  Create new ftp server. Parameters are: connection port, ascii file contain users and passwords and the packet size.                         *
 *  The format of the file is:                                                                                                                  *
 *                                   [USER] [PASSWORD]                                                                                          *
 *                                   [USER] [PASSWORD]                                                                                          *
 *                                   ...                                                                                                        *
 *  Example:        yosi A9Ghds                                                                                                                 *
 *                  rita BnFghg                                                                                                                 *
 *  The size of name and password is maximum 8 characters each.                                                                                 *
 *  Return FtpServer pointer, on failure return 0 and prints the cause of failure to stderr. Failure can occure from allocation errors or       *
 *  connection errors.                                                                                                                          */
FtpServer* FtpServerNew(int _port,char* _fileName, size_t _packetSize);

/*  Delete the ftp server                                                                                                                       */
void FtpServerDelete(FtpServer* );

/*  Run the ftp server for forever loop. Can exit by enter any key.                                                                             */
int FtpServerRun(FtpServer* );









#endif /* __FTPSERVER_H__   */
